package com.sttg.csp.registration.service;

import java.util.List;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.sttg.csp.common.exception.BizException;
import com.sttg.csp.common.service.LoginService;
import com.sttg.csp.registration.dao.BDUserRegDAO;

public class BDUserRegService {

	/**
	 * Logger for this class
	 */
	private final Log logger = LogFactory.getLog(LoginService.class);

	private static final BDUserRegService instance = new BDUserRegService();    

	private BDUserRegDAO bDUserRegDAO = BDUserRegDAO.getInstance();
	/** 
	 * Private the default constructor.
	 */   
	private BDUserRegService() {}    
   
	/** 
	 * Static factory methods.
	 */   
	public static BDUserRegService getInstance() {
		return instance;    
	}    

	public Map queryObject(Map param) throws BizException {
		String uid = (String) param.get("CN");
		if (uid == null || "".equals(uid)) {
			throw new BizException("CN of BD certificate association record can't null");
		}
		return bDUserRegDAO.queryBDUserReg(param);
	}
	
	public List queryList(Map param) throws BizException {
		return bDUserRegDAO.queryBDUserRegList(param);
	}
	
	/**
	 * @param param will save the B/D User self-registration info.
	 * @throws BizException
	 */
	public void doInsert(Map param) throws BizException {
		bDUserRegDAO.doInsertBDUserReg(param);
	}
	
	/**
	 * @param param will modify the B/D User self-registration info.
	 * @throws BizException
	 */
	public void doUpdate(Map param) throws BizException {
		bDUserRegDAO.doUpdateBDUserReg(param);
	}
}
